<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 郑帅
  Date: 2019/8/17
  Time: 14:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>

<script src="<c:url value="/layui/layui.js"/>"></script>
<link rel="stylesheet" type="text/css" href="<c:url value="/layui/css/layui.css"/>">
<body>

<%--<div id="demo20"></div>--%> <%--<ul id="biuuu_city_list"></ul>--%>
<div class="demoTable">
    类 别：
    <div class="layui-inline">
        <input class="layui-input" name="id" id="name" autocomplete="off">
    </div>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp

    型号：
    <div class="layui-inline">
        <input class="layui-input" name="id" id="xh" autocomplete="off">
    </div>

    批次：
    <div class="layui-inline">
        <input class="layui-input" name="id" id="pc" autocomplete="off">
    </div>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp

    <button class="layui-btn" data-type="reload" id="ss">搜索</button>
</div>

</div>
<table class="layui-hide" id="test" lay-filter="test" height=100></table>

<script src="<c:url value="/layui/layui.js"/>" charset="utf-8"></script>
<script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
<script>
    $(function () {
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#test',
                url: '<c:url value="/Spcx.do"/>',
                cellMinWidth: 95,
                page: true,
                height: "full-125",
                limits: [5, 10, 15, 20],
                limit: 5,
                id: "userListTable",

                height: "420px",
                response: {
                    statusName: 'code',// 对应 code
                    msgName: 'mag', // 对应 msg
                    countName: 'count', // 对应 count
                    dataName: 'data'  // 对应 data
                },

                cols: [[

                    // {field: 'stuid', title: 'ID', minWidth:100, align:"center"},
                    // {field: 'stuname', title: '姓名', align:'center'},
                    // {field: 'stuage', title: '年龄', align:'center',minWidth:150},
                    // {fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
                    {field: 'id', title: '编号', minWidth: 100, align: "center"},
                    {field: 'name', title: '名称', align: 'center'},
                    {field: 'version', title: '型号', align: 'center', minWidth: 150},
                    {field: 'batch', title: '等级/批次', minWidth: 100, align: "center",width:200},
                    {field: 'unit', title: '单位', minWidth: 100, align: "center",width:200},
                    {field: 'price', title: '单价', minWidth: 100, align: "center",width:200},
                    {field: 'remarks', title: '备注', align: 'center', minWidth: 150},
                ]]

            });
            table.on('tool(test)', function (obj) {
                var data = obj.data;
                console.log(data.id);
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        obj.del();
                        qrLs(data.id);
                        layer.close(index);
                    });
                } else if (obj.event === 'edit') {
                    zhLs(obj.data.id);
                }

            });
        });

        function qrLs(id) {
            //  确认流失
        }

        function zhLs(id) {

            <%--location.href = '<c:url value="/#?id="/>' + id;--%>
            //展缓流失

        }
        $("#ss").click(function () {
            var name = $("#name").val();

            var xh = $("#xh").val();

            var pc = $("#pc").val();
            layui.use('table', function () {
                var table = layui.table;
                table.render({
                    elem: '#test',
                    where: {
                        "name": name,
                        "xh": xh,
                        "pc": pc,

                    },
                    url: '<c:url value="/SpQuery.do"/>',
                    cellMinWidth: 95,
                    page: true,
                    height: "full-125",
                    limits: [5, 10, 15, 20],
                    limit: 5,

                    id: "ListTable",
                    height: "420px",
                    response: {
                        statusName: 'code', // 对应 code
                        msgName: 'mag',     // 对应 msg
                        countName: 'count', // 对应 count
                        dataName: 'data'    // 对应 data
                    }
                    ,
                    cols: [[
                        // {field: 'stuid', title: 'ID', minWidth:100, align:"center"},
                        // {field: 'stuname', title: '姓名', align:'center'},
                        // {field: 'stuage', title: '年龄', align:'center',minWidth:150},
                        // {fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
                        {field: 'id', title: '编号', minWidth: 100, align: "center"},
                        {field: 'name', title: '名称', align: 'center'},
                        {field: 'version', title: '型号', align: 'center', minWidth: 150},
                        {field: 'batch', title: '等级/批次', minWidth: 100, align: "center",width:200},
                        {field: 'unit', title: '单位', minWidth: 100, align: "center",width:200},
                        {field: 'price', title: '单价', minWidth: 100, align: "center",width:200},
                        {field: 'remarks', title: '备注', align: 'center', minWidth: 150},
                    ]]
                });
            });
        })
    })
</script>

</body>
</html>
